package online.flowerinsnow.minecraft.bukkit.testffa.command;

import online.flowerinsnow.minecraft.bukkit.testffa.core.TestFFACore;
import online.flowerinsnow.minecraft.bukkit.testffa.event.PlayerDiedEvent;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;

import java.util.ArrayList;
import java.util.List;

public class SuicideCommand implements TabExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if (sender instanceof Player) {
            Player player = (Player) sender;
            PlayerDiedEvent evt = new PlayerDiedEvent(player, TestFFACore.getCombatManager().getCombatTarget(player));
            Bukkit.getPluginManager().callEvent(evt);
            player.getActivePotionEffects().forEach(p -> player.removePotionEffect(p.getType()));
        }
        return true;
    }

    @Override
    public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
        return new ArrayList<>();
    }
}
